package cn.seecoder.ai.dao;

import cn.seecoder.ai.model.po.Model;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface ModelRepository extends JpaRepository<Model, Integer>, JpaSpecificationExecutor<Model> {
    @Query("select count(m) from Model m where m.configId = ?1")
    int countByConfigId(Integer configId);

    List<Model> findByUserId(Integer userId);

    List<Model> findByUserIdAndConfigId(Integer userId, Integer configId);

    List<Model> findByUserIdOrderByCreatedTimeDesc(Integer userId);
}